import Vue from 'vue'
import VueRouter from 'vue-router'

import Layout from '@/layout' //布局页

Vue.use(VueRouter)

// 通用页面, 这里的配置不需要权限
export const constRouter = [
  {
    path: '/login',
    component: () => import('@/views/login/Login'),
    hidden: true //导航菜单忽略选项
  },
  {
    path: '',
    component: Layout, //应用布局页
    redirect: '/index',
    hidden: true,
  },
  {
    path: '/index',
    component: Layout, //应用布局页
    name: 'index',
    meta: {
      title: "首页", //导航菜单项标题
      icon: 'el-icon-edit' //导航菜单图标
    },
    children: [
      {
        path: '',
        component: () => import('@/views/index/index.vue'),
        name: 'indexs',
        meta: {
          title: "首页",
          icon: 'el-icon-edit',
          roles: ['admin', 'jerry']
        }
      }
    ]
  }
]

// 动态路由
export const asyncRoutes = [
  {
    path: '/room',
    component: Layout,
    redirect: '/room/index',
    meta: {
      title: '房间管理',
      icon: 'el-icon-s-grid'
    },
    children: [
      {
        path: 'index',
        component: () => import('@/views/room/index.vue'),
        name: 'room',
        meta: {
          title: '房间列表',
          icon: 'el-icon-edit',
          hidden: false,
          roles: ['admin', 'jerry']
        }
      }
    ]
  },
  {
    path: '/order',
    component: Layout,
    redirect: '/order/index',
    meta: {
      title: '订单管理',
      icon: 'el-icon-s-grid'
    },
    children: [
      {
        path: 'index',
        component: () => import('@/views/order/index.vue'),
        name: 'order',
        meta: {
          title: '订单列表',
          icon: 'el-icon-edit',
          hidden: false,
          roles: ['admin', 'jerry']
        }
      }, {
        path: "ongoing",
        component: () => import('@/views/order/ongoing.vue'),
        name: 'ongoing',
        meta: {
          title: '待处理订单',
          icon: 'el-icon-edit',
          hidden: false,
          roles: ['admin', 'jerry']
        }
      }, {
        path: "deal",
        component: () => import('@/views/order/deal.vue'),
        name: 'ongoing',
        meta: {
          title: '待调整订单',
          icon: 'el-icon-edit',
          hidden: false,
          roles: ['admin', 'jerry']
        }
      }
    ]
  },
  {
    path: '/good',
    component: Layout,
    meta: {
      title: "商品管理",
      icon: 'el-icon-edit'
    },
    children: [
      {
        path: 'index',
        component: () => import('@/views/goods/index.vue'),
        name: 'index',
        meta: {
          title: "库存",
          icon: 'el-icon-edit',
          hidden: false,
          roles: ['admin', 'jerry']
        }
      },
      {
        path: 'goods',
        component: () => import('@/views/goods/goods.vue'),
        name: 'good',
        meta: {
          title: "产品资料",
          icon: 'el-icon-edit',
          hidden: false,
          roles: ['admin', 'jerry']
        }
      },
    ]
  },
  {
    path: '/employees',
    component: Layout,
    redirect: '/employees/index',
    meta: {
      title: "技师管理",
      icon: 'el-icon-s-goods',
      hidden: false,
    },
    children: [
      {
        path: 'index',
        component: () => import('@/views/employees/Index.vue'),
        name: 'userindex',
        meta: {
          title: "技师列表",
          icon: 'el-icon-tickets',
          hidden: false,
          roles: ['admin', 'jerry']
        }
      },
      {
        path: 'fromgood',
        component: () => import('@/views/employees/add.vue'),
        name: 'add',
        meta: {
          title: "添加技师",
          icon: 'el-icon-tickets',
          hidden: false,
          roles: ['admin'],

        }
      },
      {
        path: 'update/:id',
        component: () => import('@/views/employees/update.vue'),
        name: 'update',
        props: true,
        meta: {
          title: "修改技师信息",
          icon: 'el-icon-tickets',
          hidden: true,
          roles: ['admin', 'jerry']
        }
      },

    ]
  },
  {
    path: '/commission',
    component: Layout,
    redirect: '/commission/index',
    meta: {
      title: "提成管理",
      icon: 'el-icon-s-goods',
      hidden: false,
    },
    children: [
      {
        path: 'index',
        component: () => import('@/views/commission/Index.vue'),
        name: 'userindex',
        meta: {
          title: "服务提成列表",
          icon: 'el-icon-tickets',
          hidden: false,
          roles: ['admin', 'jerry']
        }
      },
      {
        path: 'add/:id',
        component: () => import('@/views/commission/FromCommission.vue'),
        name: 'fromuser',
        props: true,
        meta: {
          title: "添加服务提成",
          icon: 'el-icon-tickets',
          hidden: true,
          roles: ['admin', 'jerry'],

        }
      },
      {
        path: 'update/:id',
        component: () => import('@/views/commission/FromCommissionUpdate.vue'),
        name: 'update',
        props: true,
        meta: {
          title: "修改服务提成",
          icon: 'el-icon-tickets',
          hidden: true,
          roles: ['admin', 'jerry']
        }
      },

    ]
  },
  {
    path: '/settings',
    component: Layout, //应用布局页
    name: 'settings',
    meta: {
      title: "系统设置", //导航菜单项标题
      icon: 'el-icon-edit' //导航菜单图标
    },
    children: [
      {
        path: '',
        component: () => import('@/views/settings/index.vue'),
        name: 'settings',
        meta: {
          title: "系统设置",
          icon: 'el-icon-edit',
          roles: ['admin', 'jerry']
        }
      }
    ]
  }
]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes: constRouter
})

export default router

